<template>
	<div class="zhengtuojianhuo">
		<van-nav-bar :fixed="true" class="navBar" title="拣货集货" left-arrow @click-left="$router.go(-1)"></van-nav-bar>




		<div class="goodsFromWarp">
				<div class="goodsInputWarp">
						<div class="goodsInputLabel">
							<div class="goodsInputBorder"></div>
							<div class="skuName">出库容器：</div>
						</div>
						<van-field
							 class="skuInput"
							 clearable
							 v-model="editForm.jhrqid"
							 @keyup="onEnter($event,do_inputspbar)"
							 placeholder="请填写出库容器"
						 />

						 <div class="searchBtn">
						 	<button :disabled="isdisabled"  @click.stop="lingquBtn()" >
						 		<van-icon name="ellipsis" color="#1989fa"  />
						 	</button>
						 </div>
				</div>
		</div>


		<div class="carCardWarp">
			<div class="carCard" v-for="(item,index) in lingquData" :key="index">

				<div class="goodsTitleRow" style="margin-bottom: 10px;">
						<div class="goodsTitleLabel">
							<div class="skuName">门店：</div>
						</div>
						<div class="skuNoTitle">
						{{item.ck_storeid}}-{{item.storename}}
						</div>
				</div>


				<van-row class="goodRow" >
				  <van-col span="24"> <span>商品:</span>{{item.itemid}}-{{item.subname}}</van-col>
				</van-row>

				<van-row class="goodRow" >
				  <van-col span="24"> <span>波次单号:</span>{{item.bill}}</van-col>
				</van-row>

				<van-row class="goodRow" >
				  <van-col span="24"> <span>条码:</span>{{item.barcode}}</van-col>
				</van-row>

				<van-row class="goodRow" >
				  <van-col span="24"> <span>任务状态:</span>{{item.qr_status}}</van-col>
				</van-row>

				<van-row class="goodRow" >
				  <van-col span="24"> <span>任务类型:</span>{{item.rwtype}}</van-col>
				</van-row>




				<van-row class="goodRow" style="margin-top: 10px;">
				  <van-col span="12"> <span>单位:</span>{{item.username}}</van-col>
				  <van-col span="12"> <span>箱数:</span>{{item.pack}}</van-col>
				</van-row>

				<van-row class="goodRow" style="margin-top: 10px;">
				  <van-col span="12"> <span>散数:</span>{{item.qty}}</van-col>
				  <van-col span="12"> <span>预计总数:</span>{{item.yjtotqty}}</van-col>
				</van-row>

				<van-row class="goodRow" style="margin-top: 10px;">
				  <van-col span="12"> <span>商品规格:</span>{{item.specs}}</van-col>
				  <van-col span="12"> <span>商品单位:</span>{{item.kcuom}}</van-col>
				</van-row>

				<van-row class="goodRow" style="margin-top: 10px;">
				  <van-col span="12"> <span>补货仓位:</span>{{item.cwnobh}}</van-col>
				  <van-col span="12"> <span>拣货仓位:</span>{{item.cwnojh}}</van-col>
				</van-row>

				<van-row class="goodRow" style="margin-top: 10px;">
				  <van-col span="12"> <span>修改人:</span>{{item.oper_xg}}</van-col>
				  <van-col span="12"> <span>确认人:</span>{{item.qrr}}</van-col>
				</van-row>

				<van-row class="goodRow" style="margin-top: 10px;">
				  <van-col span="12"> <span>复核人:</span>{{item.oper_fh}}</van-col>
				  <van-col span="12"> <span>装车人:</span>{{item.oper_zc}}</van-col>
				</van-row>
			</div>
		</div>


	</div>
</template>

<script>

export default {
  name: 'jianhuojihuo',
  data() {
    return {
			editForm:{
				jhrqid:'',
			},
			isdisabled:false,
			lingquData:[
				{
					storename:''
				},
			],
			isLingQuVisible:false,
			skuData:[],
			isSkuVisible:false,
			index:0,
			skuRow:{},
			timeoutId: null,
			isMessageVisible:false,
			total:0,
			areElementsSame:''
		};
  },
	computed: {
		 ryuser: function(){
			 return this.GWO(true).gUSER;
		 },
	},
  methods: {
		do_inputspbar(pmtxt){
			console.log(pmtxt)  //扫描枪获取的参数
			this.editForm.jhrqid = pmtxt
			this.lingquBtn()
		},
		lingquBtn(){
			var _self = this;
			_self.total = 0
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
				'method':'dgate',
				'pname':'f_wmsa_y_jianhuo',
				'i':this.FNULLE([
				'opmode','Y_JHJH_qrybill',
				'czyid',this.ryuser.operatorid,
				'kqid', this.ryuser.kqid,
				'jhrqid',this.editForm.jhrqid,
				])
				},'复核容器查门店',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					console.log("得到复核容器查门店")
					console.log(rtn_json_obj)
					_self.lingquData = rtn_json_obj
				}
			});
		},
		saveGoodsBtn(){
			var _self = this;
			_self.total = 0
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
				'method':'dgate',
				'pname':'f_wmsa_y_jianhuo',
				'i':this.FNULLE([
				'opmode','Y_FHRQ_qryitemid',
				'czyid',this.ryuser.operatorid,
				'kqid', this.ryuser.kqid,
				'ck_storeid',this.editForm.ck_storeid,
				'jhrqid',this.editForm.jhrqid,
				])
				},'校验拣货容器',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					console.log("得到校验拣货容器")
					console.log(rtn_json_obj)
					if(rtn_json_obj[0].ret_ret == '-1'){
						_self.$toast.fail(rtn_json_obj[0].ret_mess)
						return
					}else{
						_self.$toast.fail(rtn_json_obj[0].ret_mess)
						_self.editStatus()
					}
				}
			});
		},
		editStatus(){
			console.log("容器编号")
			console.log(this.editForm.jhrqid)
			this.lingquData.forEach((row)=>{
				if(this.editForm.jhrqid == row.jhrq){
					console.log(row.jhrq)
					row.yn_fuhe = 'Y'
				}
			})
			this.editForm.jhrqid = ''

			const firstElement = this.lingquData[0].yn_fuhe;
			return this.areElementsSame =  this.lingquData.every(element => element.yn_fuhe === firstElement);
		},
  },
  mounted() {

  },
	components: {

	},
};
</script>

<style lang="scss" scoped>
	// 引入公共样式
	@import '@/assets/css/base.scss';
	@import '@/assets/css/input.scss';
	div.zhengtuojianhuo{
		padding-top: 50px;
	}



	div.carCardWarp{
		width: 94%;
		margin-left: 3%;
		margin-right: 3%;
		margin-top: 20px;
		font-size:20px;
		font-weight: bold;
		div.carCard{
			position: relative;
			border-left: 5px solid #4998FF;
			box-sizing: border-box;
			padding-left: 5px;
			padding-right: 5px;
			border-radius:5px;
			background-color: #fff;
			padding-top: 10px;
			padding-bottom: 10px;
			margin-bottom:15px;
			div.status{
				position: absolute;
				right: 0;
				top: 0;
				width: 65px;
				height: 30px;
				display: flex;
				align-items: center;
				justify-content: center;
				color: #fff;
				font-size: 12px;
				border-radius: 0px 10px 0px 10px;
			}
			div.goodRow{
				margin-bottom:8px;
				span{
					display: inline-block;
					width:100px;
				}
			}
			div.goodsTitleRow{
				display: flex;
				width: 100%;
				div.goodsTitleLabel{
					width: 100px;
				}
				div.skuNoTitle{
					width: calc(100% - 100px);
				}
			}
		}
	}
</style>
